<?php

namespace backend\models\course;

use Yii;
use backend\models\course\CourseJoint;
use backend\models\course\CoursePeriod;
/**
 * This is the model class for table "{{%edu_course_section}}".
 *
 * @property integer $section_id
 * @property integer $course_id
 * @property integer $section_num
 * @property string $section_name
 * @property integer $section_addtime
 */
class CourseSection extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%course_section}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['course_id', 'section_num', 'section_name', 'section_addtime'], 'required'],
            [['course_id', 'section_num', 'section_addtime'], 'integer'],
            [['section_name'], 'string', 'max' => 100]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'section_id' => 'Section ID',
            'course_id' => 'Course ID',
            'section_num' => 'Section Num',
            'section_name' => 'Section Name',
            'section_addtime' => 'Section Addtime',
        ];
    }

    //章与节的关系

    public function getJoint()
    {
        return $this->hasMany(CourseJoint::className(),['section_id'=>'section_id']);
    }
   /* //章与课时的关系
    public function getPeriod()
    {   
        $db = new CourseJoint;
        return $db ->hasMany(CoursePeriod::className(),['Joint_id'=>'Joint_id']);
    }*/
}
